package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.graphics.Paint;
import android.text.TextUtils;
import android.view.View;

import androidx.core.util.Pair;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemMaterialGoods1Binding;
import com.sgb.kjwl.databinding.ItemMaterialGoodsBinding;
import com.sgb.kjwl.model.entity.SearchMaterialEntity3;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.PointUtils;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.adapter.enterprise.TextViewBindingAdapter;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MToast;

import java.text.DecimalFormat;
import java.util.List;

public class MaterialHomeAdapter1 extends BaseRecycleAdapter<SearchMaterialEntity3> {

    public MaterialHomeAdapter1(Context context, List<SearchMaterialEntity3> datas) {
        super(context, R.layout.item_material_goods1, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SearchMaterialEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemMaterialGoods1Binding itemMaterialGoods1Binding = (ItemMaterialGoods1Binding) holder.getmBinding();
        if ("1".equals(entity.getSelfSupportTag())) {
            itemMaterialGoods1Binding.selfSupport.setVisibility(View.VISIBLE);
        } else {
            itemMaterialGoods1Binding.selfSupport.setVisibility(View.GONE);
        }
        itemMaterialGoods1Binding.tvStorageName.setText("仓储:" + entity.getStorageName());
        itemMaterialGoods1Binding.contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(entity.getCompanyNo())){
                    MToast.showToast(context,"该企业信息不正确");
                    return;
                }
                WebsiteInfoActivity.start(context, entity.getCompanyNo(), 1);
            }
        });
    }
}
